﻿using BussinessObject.ObjectTwo;
using Class_Entity.ObjectTwo;
using ProjectHK3.App_Code;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ProjectHK3.Object_One
{
    public partial class CityDetail : System.Web.UI.Page
    {
        B_Search ex = new B_Search();
        B_Update sx = new B_Update();
        Cities fx = new Cities();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                load();
            }
        }
        public void load()
        {
           fx = ex.loadCity(int.Parse(Session["city"].ToString()));
            TextBox1.Text = fx.CITY_CODE;
            TextBox2.Text = fx.CITY_NAME;
            TextBox3.Text = fx.DESCRIPTION;
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            fx.CITY_ID = int.Parse(Session["city"].ToString());
            fx.CITY_CODE = TextBox1.Text;
            fx.CITY_NAME = TextBox2.Text;
            fx.DESCRIPTION = TextBox3.Text;
            if (sx.updateCity(fx) == true)
            {
                Alert.Show("OK");
                load();
            }
            else
            {
                Alert.Show("false");
                load();
            }
            ;
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            TextBox1.Text = "";
            TextBox2.Text = "";
            TextBox3.Text = "";
            TextBox1.Focus();
        }
    }
}